//==============================================================================
//
//               Copyright (C) 2002  Dick van Oudheusden
//  
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free
// Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
//==============================================================================
// 
//  $Date: 2003-10-31 08:12:35 $ $Revision: 1.1 $
//
//==============================================================================

#include <stdlib.h>

#include "ofc/config.h"

#include "ofc/DLong.h"

#include "DInc.h"
#include "DTest.h"

//-DataTypes-------------------------------------------------------------------

void DLong_test()
{
  DLong *i = [[DLong alloc] init];
  DLong *c = [[DLong alloc] init];
  char   t[] = "9209 4";
  char   w[] = "a678";
  char  *pt;
  
  STARTTEST();
 
  TEST([i  get] == 0);
  
  TEST([[i set :7] get] == 7);
  
  TEST([[i toText] ccompare :"7"] == 0);
  
  [c set :-4];
  
  TEST([i compare :c] == 1);
  TEST([c compare :i] == -1);

  [i set :0x12345678];
  TEST([i toBigEndian]    == 0x78563412); 
  TEST([i toLittleEndian] == 0x12345678);
  
  pt = t;
  TEST([i fromString :&pt] == 0);
  TEST([i get] == 9209);
  TEST(*pt == ' ');

  pt = w;
  TEST([i fromString :&pt] == ENODATA);

  STOPTEST();
} 

